<template>
  <div>
    <el-card>
      <el-form ref="form" :model="formData" size="medium" label-width="110px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="监督机构" prop="orgName">
              <el-select
                v-model="formData.orgId" filterable clearable style="margin-left: 20px;" placeholder="请选择">
                <el-option
                  v-for="item in forname"
                  :key="item.id"
                  :label="item.orgName"
                  :value="item.id">
                </el-option>
              </el-select>

            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="年份" prop="yearly">
              <el-date-picker v-model="formData.yearly" type="year" placeholder="选择年" format="yyyy" value-format="yyyy"
                              :style="{width: '50%'}" clearable></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-col :span="4">
              <el-button type="success" @click="inquire">检索</el-button>
            </el-col>
            <el-col  :span="2">
              <download-excel
                class="export-excel-wrapper"
                :data="personlist"
                :fields="fields"
                :header="title"
                name="所级领导名录统计表.xls">
                <el-button type="warning" icon="el-icon-download" >导出</el-button>
              </download-excel>
            </el-col>
          </el-col>
        </el-row>
        <p style="margin-top: 50px"></p>
      </el-form>
      <el-table :data="personlist"
                border style="width: 100%">
        <el-table-column
          fixed
          prop="orgName"
          label="单位"
          width="180">
        </el-table-column>
        <el-table-column
          prop="leaderName"
          label="姓名"
          width="160">
        </el-table-column>
        <el-table-column
          prop="gender"
          label="性别"
          width="100">
        </el-table-column>
        <el-table-column
          prop="folk"
          label="民族"
          width="180">
        </el-table-column>
        <el-table-column
          prop="birthDate"
          label="出生年月"
          width="180">
        </el-table-column>
        <el-table-column
          prop="pol"
          label="政治面貌"
          width="140">
        </el-table-column>
        <el-table-column
          prop="edu"
          label="学位"
          width="100">
        </el-table-column>
        <el-table-column
          prop="manageJob"
          label="职务"
          width="120">
        </el-table-column>
        <el-table-column
          prop="title"
          label="职称"
          width="80">
        </el-table-column>
        <el-table-column
          prop="memo"
          label="备注"
          width="164">
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
  import {post} from "@/utils/api";

  export default {
    data() {
      return {
        personlist:[],
        formData:{},
        forname:[],
        title:"所级领导名录统计表",
        fields:{'单位':'orgName','姓名':'leaderName','性别':'gender','民族':'folk','出生年月':'birthDate','政治面貌':'pol','学位':'edu','职务':'manageJob','职称':'title','备注':'memo'}
      }
    },
    async created() {
      let res = await post("org/getallorg")
      // console.log(res)
      this.forname= res
      // console.log(this.forname)
      this.getleader()

    },
    methods: {
      async getleader() {
        let res = await post("leader/getleader")
        let data = res
        this.personlist = data.map(item=>{
          if(item.title==1)
            item.title="初级医师";
          if(item.title==2)
            item.title="初级技师";
          if(item.title==3)
            item.title="助理政工师";
          if(item.title==4)
            item.title="助理工程师";
          if(item.title==5)
            item.title="助理会计师";
          if(item.title==6)
            item.title="研究实习员";
          if(item.title==7)
            item.title="主管";
          if(item.title==8)
            item.title="主治";
          if(item.title==9)
            item.title="中级医师";
          if(item.title==10)
            item.title="中级技师";
          if(item.title==11)
            item.title="政工师";
          if(item.title==12)
            item.title="馆员";
          if(item.title==13)
            item.title="工程师";
          if(item.title==14)
            item.title="会计师";
          if(item.title==15)
            item.title="副主任医师";
          if(item.title==16)
            item.title="副主任技师";
          if(item.title==17)
            item.title="高级政工师";
          if(item.title==18)
            item.title="高级会计师";
          if(item.title==19)
            item.title="主任医师";
          if(item.title==20)
            item.title="主任技师";
          if(item.title==21)
            item.title="无职称";
          if(item.title==22)
            item.title="未聘任专业技术职务";
          if(item.title==23)
            item.title="不详";
          return item
        })
        console.log(res)
      },
      //按条件查询
      async inquire(){
        let res= await post("leader/getbyoidoryearly",{...this.formData})
        this.personlist = res
        console.log(res)
      },

    }
  }
</script>
<style></style>
